import basic from './basic.js';
var actmodel = new basic();
actmodel.do="cashout_cont"
//获取余额
actmodel.brokerage=function(id,type){
  var app = getApp();
  var data = { "op": "brokerage",id,type }
  var that= this;
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/' + actmodel.do,
      'data': data,
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {                 
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}
//提现
actmodel.withdrawal=function(formdata,type){
  var app = getApp();
var data={}
  switch(type){
    case "club":{
      var actleadgroup = app.globalData.actleadgroup;
      var data = { "op": "withdrawal",formdata,type,id:actleadgroup.id }
      break;
    }
    case "distr":{
        var member_id=app.globalData.member.member_id
      var data = { "op": "withdrawal",formdata,type,id:member_id }
      break;
    }
    case "money":{
      var member_id=app.globalData.member.member_id
      var data = { "op": "withdrawal",formdata,type,id:member_id }
      break;
    }
    case "amount":{
      var member_id=app.globalData.member.member_id
      var data = { "op": "withdrawal",formdata,type,id:member_id }
      break;
    }
  }

  var that= this;
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/' + actmodel.do,
      'data': data,
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {                 
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}

actmodel.offset = function (that, reset, para, xcsorts) {
  if (!xcsorts) {
    xcsorts = [["createtime", "desc"]];
  }

  var acturlpara = {};
  acturlpara["url"] = "entry/wxapp/"+actmodel.do
  if (para) {
    para["op"] = "offset"
  }
  else {
    this.wherepara["op"] = "offset"
  }
  return actmodel.pagelist(acturlpara, that, reset, para, xcsorts);
}
module.exports = actmodel;